﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Sakura.Media.AviSynth.Native
{
	/// <summary>
	/// 表示一个过滤器信息。
	/// </summary>
	[StructLayout(LayoutKind.Sequential)]
	[DefaultCharSet(CharSet.Ansi)]
	public struct AvsFilterInfo
	{
		/// <summary>
		/// 对应的剪辑的指针。
		/// </summary>
		public IntPtr Child;
		/// <summary>
		/// 视频信息。
		/// </summary>
		public AvsVideoInfo VideoInfo;
		/// <summary>
		/// 环境信息的指针。
		/// </summary>
		public IntPtr Env;

		/// <summary>
		/// 用于获取帧信息的回调对象。
		/// </summary>
		public GetFrameFunc GetFrameCallback;
		/// <summary>
		/// 获得帧的奇偶性的回调函数。
		/// </summary>
		public GetParityFunc GetParityCallback;
		/// <summary>
		/// 获得音频数据的回调函数。
		/// </summary>
		public GetAudioFunc GetAudioCallback;
		/// <summary>
		/// 设置搜索提示的回调函数。
		/// </summary>
		public SetCacheHintsFunc SetCacheHintsCallback;
		/// <summary>
		/// 释放过滤器的回调函数。
		/// </summary>
		public FreeFilterFunc FreeFilterCallback; 

		// these members should not be modified outside of the AVS_ApplyFunc callback
		//AVS_Clip * child;
		//AVS_VideoInfo vi;
		//AVS_ScriptEnvironment * env;
		//AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);
		//int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
		//int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf, 
		//                INT64 start, INT64 count);
		//int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints, 
		//                  int frame_range);
		//void (AVSC_CC * free_filter)(AVS_FilterInfo *);

		//// Should be set when ever there is an error to report.
		//// It is cleared before any of the above methods are called
		//const char * error;
		//// this is to store whatever and may be modified at will
		//void * user_data;

		/// <summary>
		/// 如果产生了任何错误，则用此字段表示错误信息。
		/// </summary>
		[MarshalAs(UnmanagedType.LPStr)]
		public string Error;
		/// <summary>
		/// 其他相关的用户数据。
		/// </summary>
		public IntPtr UserData;
	}
}
